package com.leiduoduo.oms.service;

import com.leiduoduo.oms.dao.TipOffDao;
import com.leiduoduo.oms.pojo.TipOff;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class TipOffServiceImpl implements TipOffService {
    @Autowired
    TipOffDao tipOffDao;

    @Override
    public boolean addTipOff(TipOff tipOff) {
        tipOff.setCreated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
                .setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return tipOffDao.addTipOff(tipOff);
    }

    @Override
    public boolean delTipOff(TipOff tipOff) {
        tipOff.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return tipOffDao.delTipOff(tipOff);
    }

    @Override
    public boolean upTipOff(TipOff tipOff) {
        tipOff.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return tipOffDao.upTipOff(tipOff);
    }

    @Override
    public TipOff getTipOffById(int id) {
        return tipOffDao.getTipOffById(id);
    }

    @Override
    public List<TipOff> getTipOffList() {
        return tipOffDao.getTipOffList();
    }
}
